<?php
require_once('controller/auth.php');
?>
<?php
require_once('controller/auth.php');
//Start session
	@session_start();
	
	//Include database connection details
	require_once('controller/inc/config.inc');
	
	//Array to store validation errors
	$errmsg_arr = array();
	
	//Validation error flag
	$errflag = false;
	
	//Connect to mysql server
	$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
	if(!$link) {
		die('Failed to connect to server: ' . mysql_error());
	}
	
	//Select database
	$db = mysql_select_db(DB_DATABASE);
	if(!$db) {
		die("Unable to select database");
	}
	
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html lang='en' xmlns='http://www.w3.org/1999/xhtml'>
<head>
<meta content='text/html; charset=utf-8' http-equiv='Content-Type' />
<title>Project Tracking MIS</title>

<!-- Le HTML5 shim, for IE6-8 support of HTML elements -->
<!--[if lt IE 9]>
<script src="https://html5shim.googlecode.com/svn/trunk/html5.js" type="text/javascript"></script>
<![endif]-->
<!-- Le styles -->
<link rel="stylesheet" href="assets/css/bootstrap.css" type="text/css" />
<link rel="stylesheet" href="assets/css/bootstrap-responsive.css" type="text/css" />
<link rel="stylesheet" href="assets/css/font-awesome.css" type="text/css" />
<script type="text/javascript" src="assets/js/jquery.min.js"></script>

<script type="text/javascript" src="assets/js/bootstrap.min.js"></script>
<script type="text/javascript" src="assets/js/bootstrap-popover.js"></script>
<script type="text/javascript" src="assets/js/bootstrap-tooltip.js"></script>
<script>
$(function ()
{ 
$("input").popover({trigger: 'focus', 'placement':'right'});

$("textarea").popover({trigger: 'focus'});


$('#tab').tooltip({'placement':'right', 'trigger' : 'hover'});

$('a').tooltip({'placement':'bottom', 'trigger' : 'hover'});	
});
</script>
<script type="text/javascript">
$(document).ready(function()
{
$("#subbtn").click(function()
{

var pro_name=$('#pname').val();
var pro_number=$('#prnumber').val();
var p_amount=$('#amount').val();
var f_location=$('#flocation').val();
var desc=$('#desc').val();
var dt=$('#dt').val();
var est_day=$('#est_ted').val();
var sub_name=$('#sub_name').val();
var dataString = 'pro_name='+ pro_name + '&proNo='+ pro_number + '&pAm='+ p_amount + '&fLoc='+ f_location + '&desc='+ desc + '&dt='+dt +'&estdt='+est_day+'&sub_name='+sub_name;

$.ajax
({
type: "POST",
url: "controller/execute/save_project.php",
data: dataString,
cache: false,
success: function(html)
{
$("#saveResult").html(html);
$('#myModal').modal('show');
$('#pname').val('');
$('#prnumber').val('');
$('#amount').val('');
$('#flocation').val('');
$('#desc').val('');
$('#dt').val('');
$('#est_ted').val('');
$('#sub_name').val('');

} 
});

});

});
</script>
<style>
body {
    padding-top: 60px;
    padding-bottom: 40px;
}

.sidebar-nav {
    padding: 9px 0;
}

.dropdown-menu .sub-menu {
    left: 100%;
    position: absolute;
    top: 0;
    visibility: hidden;
    margin-top: -1px;
}

.dropdown-menu li:hover .sub-menu {
    visibility: visible;
    display: block;
}

.navbar .sub-menu:before {
    border-bottom: 7px solid transparent;
    border-left: none;
    border-right: 7px solid rgba(0, 0, 0, 0.2);
    border-top: 7px solid transparent;
    left: -7px;
    top: 10px;
}
.navbar .sub-menu:after {
    border-top: 6px solid transparent;
    border-left: none;
    border-right: 6px solid #fff;
    border-bottom: 6px solid transparent;
    left: 10px;
    top: 11px;
    left: -6px;
}
</style>
<!-- Le fav and touch icons -->

</head>

<body>
<div class="container-fluid">
<!--TOp Nav-->
<div class="navbar navbar-inverse navbar-fixed-top">
  <div class="navbar-inner">
      <div class="container-fluid">
        <a data-target=".nav-collapse" data-toggle="collapse" class="btn btn-navbar">
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
        </a>
        <a href="#" class="brand">TMIS | Project Tracking</a>
        <div class="nav-collapse">
          <ul class="nav">
            <li><a href="dashboard.php">Home Page</a></li>
            <li class="active"><a href="#">Create Project</a></li>
            <li><a href="update_project.php">Update Project</a></li>
            <li><a href="#">Reports</a></li>
          
        
          
            
            
            
          </ul>
          <form action="" class="navbar-search pull-left">
            <input type="text" placeholder="Search" class="search-query span2">
          </form>
          <ul class="nav pull-right">
            
            
            <div class="pull-right">
                <ul class="nav pull-right">
                    <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">Welcome, <?php echo $_SESSION['SESS_FIRST_NAME'] . " " . $_SESSION['SESS_LAST_NAME'];?> <b class="caret"></b></a>
                        <ul class="dropdown-menu">
                            <li><a href="/user/preferences"><i class="icon-cog"></i> Preferences</a></li>
                            <li><a href="/help/support"><i class="icon-envelope"></i> Contact Support</a></li>
                            <li class="divider"></li>
                            <li><a href="controller/logout.php"><i class="icon-off"></i> Logout</a></li>
                        </ul>
                    </li>
                </ul>
              </div>
              
              
          </ul>
        </div><!-- /.nav-collapse -->
      </div>
  </div>
</div>








<script>
$(document).ready(function()
{
  //Handles menu drop down
  $('.dropdown-menu').find('form').click(function (e) {
        e.stopPropagation();
        });
  });
</script>

   <script type = "text/javascript">
$(function() {
	//call the function onload
	getdata( 1 );
});

function getdata( pageno ){                     
	var targetURL = 'pagination/search_results.php?page=' + pageno;   

	$('#retrieved-data').html('<p><img src="pagination/ajax-loader.gif" /></p>');        
	$('#retrieved-data').load( targetURL ).hide().fadeIn('slow');
}      
</script>

<!--/Top Nav-->
  <div class="row-fluid">
    
    <div class="span12">
	<!--Content-->
<div id='saveResult'></div>

<div class="form-horizontal">
  <fieldset>
    <div id="legend">
      <legend class="">Create Project</legend>
    </div>
    <div class="control-group">
      <!-- Username -->
      <label class="control-label">Project Name</label>
      <div class="controls">
        <input type="text" id='pname' name="pname" placeholder="" class="input-xlarge">
        <p class="help-block">Enter a short name for your project</p>
      </div>
    </div>

    <div class="control-group">
      <!-- E-mail -->
      <label class="control-label">Project Request Number</label>
      <div class="controls">
        <input type="text" id='prnumber' name="prnumber" placeholder="" class="input-xlarge">
        <p class="help-block">Please provide Project Number (e.g 1342)</p>
      </div>
    </div>

    <div class="control-group">
      <!-- Password-->
      <label class="control-label">Amount</label>
      <div class="controls">
        <input type="text" id='amount' name="amount" placeholder="" class="input-xlarge">
        <p class="help-block">Project Amount in USD or AF (e.g. $1,200 or AF 50,000)</p>
      </div>
    </div>
    <div class="control-group">
      <!-- Password-->
      <label class="control-label">Physical File Location</label>
      <div class="controls">
        <input type="text" id='flocation' name="flocation"  class="input-xlarge">
        <p class="help-block">Relevant file location for this project(e.g. Salary Folder)</p>
      </div>
    </div>
     <div class="control-group">
      <!-- Password-->
      <label class="control-label">Expected TED Approval</label>
      <div class="controls">
        <input type="text" id='est_ted'  placeholder='Number of Days' class="input-xlarge">
        <p class="help-block">Number of estimated days for getting TED Approval.</p>
      </div>
    </div>
    
    
    <div class="controls-group">
    <label class="control-label">Project Description</label>
      <div class="controls">
          <textarea id="desc" name="desc" class="span6" placeholder="Project Description" rows="5"></textarea>
      </div>
    </div>
    
    
    
    
    
    <input type='hidden' value ='<?php echo $today = date("Y-m-d"); ?>' id='dt'>
    <input type='hidden' value ='<?php echo $_SESSION['SESS_FIRST_NAME'] . " " . $_SESSION['SESS_LAST_NAME']; ?>' id='sub_name'>
    <div class="clearfix"></div><br/>
    <div class="control-group">
      <!-- Button -->
      <div class="controls">
        <button class="btn btn-success" id='subbtn'>Create Project</button>
      </div>
    </div>
  </fieldset>
</div>


	<!--/Content-->
	
    </div>
	
	

  </div>
  <hr/>
  <footer class="footer">
  &copy;2013 TMIS, TED, MoE
  </footer>
</div>

</body>

</html>